/**
*      author: Y_Yao
*      created: 2025-03-19 17:13:38
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 9e18;
const int INF = 0x3f3f3f3f;
const int N = 5e5 + 7;
int n;
vector<int> ans;
bool check1(string& s,string& t)
{
    int diff = 0;
    for(int i = 0;i < s.size();i++)
    {
        if(s[i] != t[i])
        {
            diff++;
        }
    }
    return diff <= 1;
}

bool check2(string& src,string& tar)
{
    int left = 0,right = src.size() - 1;
    for(int i = 0;i < tar.size();i++)
    {
        left = i;
        if(src[i] != tar[i])break;
    }
    int p1 = src.size() - 1,p2 = tar.size() - 1;
    while(src[p1] == tar[p2])
    {
        p1--,p2--;
        right = p1 + 1;
    }
    return (right - left) <= 1;
}

void solve()
{
    cin >> n;
    string s;
    cin >> s;
    for(int i = 1;i <= n;i++)
    {
        string t;
        cin >> t;
        if(abs((int)s.size() - (int)t.size()) > 1)
        {
            continue;
        }
        if(s.size() == t.size())
        {
            if(check1(s,t))
            {
                ans.push_back(i);
            }
        }
        if(s.size() == t.size() + 1)
        {
            if(check2(s,t)) ans.push_back(i);
        }
        if(s.size() + 1 == t.size())
        {
            if(check2(t,s)) ans.push_back(i);
        }
    }
    cout << ans.size() << endl;
    for(auto& e : ans)
    {
        cout << e << " ";
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}